<?php
//商家分类
class CategoryModel extends Model {
	
	/*
	*	获取分类
	*	@param $pcid int 上级分类id
	*/
	public function getcate($pcid=false)
	{
		//获取分类
		$M = M('category');

		if($pcid) 
			$map=array('status'=>1,'pid'=>$pcid);
		else
			$map=array('status'=>1);

		$res = $M->where($map)->select();
		$cate = array();
		foreach($res as $val)
		{
			if($val['pid']==0)
				$cate[$val['id']]=$val;
			else
				$cate[$val['pid']]['sub'][$val['id']] = $val;
		}
		return $cate;
	}



}

